#include <gui/window.h>


Window::Window(Widget* parent,int32_t x, int32_t y, int32_t w, int32_t h,
            int32_t r, int32_t g, int32_t b)
:CompositeWidget(parent, x, y, w, h, r, g, b)
{
    dragging = false;

}

Window::~Window()
{


}



void Window::OnMouseDwon(int32_t x, int32_t y, uint8_t button){

    dragging = button == 0;
    CompositeWidget::OnMouseDwon(x, y, button);

}
void Window::OnMouseUp(int32_t x, int32_t y, uint8_t button){

    dragging = false;
    CompositeWidget::OnMouseUp(x, y, button);

}
void Window::OnMouseMove(int32_t oldX, int32_t oldY, int32_t newX, int32_t newY){

    if(dragging){

        this->x += newX - oldX;
        this->y += newY - oldY;

    }
    CompositeWidget::OnMouseMove(oldX, oldY, newX, newY);
}